<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

//Route::get('/', function () {   return view('welcome');});




//开发测试
Route::get('/dev/start', function () {
    return view('welcome');
});
Route::get('/dev', 'DevDemoController@index');
Route::get('/dev/demo', 'DevDemoController@devdemo');
//Route::get('/dev/error/404', 'errors.404');
//Route::get('/dev/error/503', 'errors.503');
Route::get('/dev/error/404', function () {return view('errors.404');});
Route::get('/dev/error/503', function () {return view('errors.503');});
Route::get('/dev/ajax', 'DevDemoController@ajax');
Route::get('/dev/ajaxdemo', 'DevDemoController@ajaxdemo');



//网站首页
Route::get('/', 'ArticleController@lists');
Route::get('/index', 'ArticleController@lists');
Route::get('/index.html', 'ArticleController@lists');
Route::get('/index.php', 'ArticleController@lists');

//文章的详情显示页面
Route::get('/article/{id}', [
	'uses'=>'ArticleController@show',
	'as'=>'detail'    //路由别名 ，方便部分路由更改时，已有链接因变更而失效。
	]);
Route::get('/articles', 'ArticleController@lists');

//登陆的页面显示
Route::get('/login', 'LoginController@login');
Route::post('/login','LoginController@dologin');
Route::get('/logout', 'LoginController@logout');


//后台路由组
Route::group(['middleware'=>'login'], function(){
	//后台路由规则
	Route::get('/admin', 'AdminController@index');
	//用户管理
	Route::get('/admin/user', 'UserController@index');
	Route::get('/admin/user/add', 'UserController@add');
	Route::post('/admin/user/insert', 'UserController@insert');
	Route::get('/admin/user/index', 'UserController@index');
	Route::get('/admin/user/lists', 'UserController@lists');
	Route::get('/admin/user/edit/{id}', 'UserController@edit');
	Route::post('/admin/user/edit/{id}', 'UserController@edit');
	Route::get('/admin/user/query', 'UserController@query');
	Route::post('/admin/user/name', 'UserController@queryByName');
	Route::get('/admin/user/show/{id}', 'UserController@show');
	Route::post('/admin/user/update', 'UserController@update');
	Route::get('/admin/user/delete/{id}', 'UserController@delete');

	//restful 控制器  一条规则顶七条
	//文章分类
	Route::resource('/admin/cate', 'CatesController');
	//标签
	Route::resource('/admin/tag', 'TagController');
	//文章
	Route::resource('/admin/article', 'ArticleController');

});


